-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Spear.append/3
raw?: true
raw return
#97
fix: Spear.append/3
raw?: true
raw return
#97
Conversation
Issue NFIBrokerage#96 Passing a `raw?: true` option to `Spear.append/3` or `Spear.Client/append` continued to return `:ok` instead of `{:ok, AppendResp.t()}`. This contradicted the docs and the `Spear.append_batch/5` behaviour. Solution: This commit adds the conditional case in `Spear.append/3` to return `{:ok, AppendResp.t()}` when `raw?` is `true`. `Spear.Client.append` will also be fixed as a result. Additional Notes: * Added to `SpearTest`: to test `append/3` for both raw true and false * Added to `SpearTest`: to test `append_batch/5` for both raw true and false. * Updated the `Spear.append/3` type spec to add the missing `{:ok, AppendResp.t()}` return type. * Updated the `Spear.Client.append/3` and `Spear.Client.append/4` callback specs to add the missing `{:ok, AppendResp.t()}` return type.
Pull Request Test Coverage Report for Build a291c791a6e7786e9868d68811a6871b39058db7-PR-97Details
💛 - Coveralls |
I dev'd against I copy-pasta'd from other append_batch test... so, those errors between 20.10.2 vs 22.6 "Compatibility / Bless"? Maybe I misunderstood compatibility, and should've copied in the tag too?
Also, not sure why "CI / Bless" is saying A local |
adding compat tag to the append_batch tests, which weren't carried over from the append_batch test copy pasting.
Fixes a `mix format --check-formatted` issue in `spear_test.exs` that was caught with Elixir 1.14, vs not catching in Elixir 1.16.2.
The formatting might be caused by changes to I think it would be ok to bump those but it should be a separate change from this fix |
Yeah the compatibility checks are there to make sure we can run against older EventStoreDB releases and with older Elixir/Erlang versions. I believe the batch append RPC was introduced in 21.6.0 so we can't run tests against it on all versions of the matrix |
Before, it was pulling out the "result", now we're returning the raw proto
1. fixes the unintentionally added extra nesting of `{:ok, {:ok, resp}}` Instead, when success and raw flag set, returns `{:ok, raw_response_pb}`. 2. Adds the extra raw response check so that `append/3` returns `{:error, raw_unexpected_version_response_pb}` if there is the wrong expected version response AND raw flag set. If I just did ``` {:ok, response} when raw? == true -> {:ok, response} ``` An `{:ok, raw_unexpected_version_response_pb}` could have been returned on unexpected version error response.
`raw?: true` cases regardless of `:success` or `:wrong_expected_version` Also, cleans up the test cases to use `Streams.append_resp` pattern matching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
In retrospect I wish the return of Spear.append/3
was {ok, metadata}
with a small map or struct that had the extra metadata in the append response rather than just ok
. It would be a breaking change though so I don't think it's worth making it at this point.
revision: 4 | ||
} | ||
|
||
assert {:success, Streams.batch_append_resp_success()} = result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that this behaves differently on Elixir 1.7. I want to bump the versions anyway though so I will merge this as-is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience in the collaboration. It was also a learning experience for me, e.g. grpc in the erlang ecosystem, to gain more knowledge about event store db and this spear library (which will be a key part in my new project).
I'm definitely open to contribute again if/when things pop up as I use spear. 👍
Context
Issue #96
Passing a
raw?: true
option toSpear.append/3
orSpear.Client/append
continued to return:ok
instead of{:ok, AppendResp.t()}
.This contradicted the docs and the
Spear.append_batch/5
behaviour.Solution
This commit adds the conditional case in
Spear.append/3
to return{:ok, AppendResp.t()}
whenraw?
istrue
.Spear.Client.append
will also be fixed as a result.Additional Notes
SpearTest
: to testappend/3
for both raw true and falseSpearTest
: to testappend_batch/5
for both raw true and false.Spear.append/3
type spec to add the missing{:ok, AppendResp.t()}
return type.Spear.Client.append/3
andSpear.Client.append/4
callback specs to add the missing{:ok, AppendResp.t()}
return type.